/*Declaring needed libraries for that task*/
import java.util.Scanner;
import java.lang.String;
import java.lang.Math;
import java.util.Arrays;

public class DayOfTheWeek
{
	public static void main(String[] args)
	{
		String[] Months_list = {"January","February","March","April","May","June","July",
								"August","September","October","November","December"};

		String[] days = {"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
		
		/*Creating Scanner and reading inout data from the user:*/
		Scanner input = new Scanner(System.in);
		System.out.print("Please enter date of the day in a month 1..31: ");
		int day = input.nextInt();
	
		System.out.print("Please enter month number 1..12: ");
	
		String month_get = input.next();
	
		/*Cheking position of the entered Month's name in the predefined array.*/
		int month = Arrays.asList(Months_list).indexOf(month_get);
		month++; /*addin 1 to the found number cuz first position in the array is 0 but in months period we use 1 as the lowest.*/
	
		System.out.print("Please enter a year in a 4-digit format XXXX: ");
		int year = input.nextInt();
	
		/*Using Zelmer's formula, calculating the naem of the day of the week:
		All constants in this formula bhave been gotten imperically by Zelmer 
		and any change of ant constant will broke the formule.*/
		int a = Math.abs((14 - month) / 12);
		int y = year - a;
		int m = month+12 * a-2;
	
		double result = ((7000 + (day + y + Math.abs(y/4) - Math.abs(y/100) + Math.abs(y/400) + Math.abs((31*m) / 12))) % 7) - 1;
		System.out.println("On the date: " + day + " " + month_get + " " + year + " the day will be: " + days[(int)result]);
	}
}